package com.cloudwise.service.impl;

import com.cloudwise.dao.CustomDao;
import com.cloudwise.entity.Custom;
import com.cloudwise.service.CustomService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Custom)表服务实现类
 *
 * @author makejava
 * @since 2020-12-23 14:56:49
 */
@Service("customService")
public class CustomServiceImpl implements CustomService {
    @Resource
    private CustomDao customDao;

    /**
     * 通过ID查询单条数据
     *
     * @param customId 主键
     * @return 实例对象
     */
    @Override
    public Custom queryById(Integer customId) {
        return this.customDao.queryById(customId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<Custom> queryAllByLimit(int offset, int limit) {
        return this.customDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param custom 实例对象
     * @return 实例对象
     */
    @Override
    public Custom insert(Custom custom) {
        this.customDao.insert(custom);
        return custom;
    }

    /**
     * 修改数据
     *
     * @param custom 实例对象
     * @return 实例对象
     */
    @Override
    public Custom update(Custom custom) {
        this.customDao.update(custom);
        return this.queryById(custom.getCustomId());
    }

    /**
     * 通过主键删除数据
     *
     * @param customId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer customId) {
        return this.customDao.deleteById(customId) > 0;
    }

    @Override
    public List<Custom> queryAllCustomByConditionAndLimit(Custom custom, int offset, int limit) {
        return customDao.queryAllCustomByConditionAndLimit(custom,offset,limit);
    }
    @Override
    public List<Custom> queryAllCustomVoByConditionAndLimit(Custom custom, int offset, int limit) {
        return customDao.queryAllCustomVoByConditionAndLimit(custom,offset,limit);
    }

    @Override
    public long getCount(Custom custom) {
        return customDao.getCount(custom);
    }
}